package com.cx.mall.goods.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.cx.mall.common.model.goods.ProductDetailDTO;
import com.cx.mall.common.utils.ResponseVO;
import com.cx.mall.common.model.goods.Product;
import com.cx.mall.goods.service.ISkuInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/goods/product")
public class ProductDTOController {
    @Autowired
    private ISkuInfoService productService;

    @GetMapping("/list")
    public ResponseVO page(Product product){
        IPage page = productService.page(product);
        return ResponseVO.success(page);
    }

    /**
     * 按SPUID获取商品详情
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public ResponseVO getById(@PathVariable Long id){
        ProductDetailDTO productDetailDTO = productService.queryById(id);
        return ResponseVO.success(productDetailDTO);
    }


}
